@extends('admin.common.layout')
@section('admin')
<table id="appStaffTable"></table>
<div id="appStaffToolBar" style="padding:10px">
<form id="fm-app-staff" action="###" method="get">

  <label class="l-btn-disabled">&nbsp;&nbsp;名&nbsp;&nbsp;称：</label><input  class="textbox" type="text" name="name" placeholder="请输入..." style="width:150px;padding:5px;"/>
  <label class="l-btn-disabled">&nbsp;&nbsp;部&nbsp;&nbsp;门：</label>
  <select class="easyui-combobox" name="dept_id" style="width:150px;height:28px;">
    <option value="">请选择</option>
    @foreach($data['depts'] as $dept)
     <option value="{{$dept['id']}}">{{$dept['name']}}</option>
    @endforeach
  </select>
  <label class="l-btn-disabled">&nbsp;&nbsp;职&nbsp;&nbsp;位：</label>
  <select class="easyui-combobox" name="post_id" style="width:150px;height:28px;">
    <option value="">请选择</option>
    @foreach($data['posts'] as $post)
     <option value="{{$post['id']}}">{{$post['name']}}</option>
    @endforeach
  </select>
  <label class="l-btn-disabled">&nbsp;&nbsp;状&nbsp;&nbsp;态：</label>
  <select class="easyui-combobox" name="status" style="width:150px;height:28px;">
    <option value="0">请选择</option>
    <option value="1">正常</option>
    <option value="2">禁用</option>
  </select>
  <input  class="textbox" type="hidden" name="type" value="ajax" />
  <button  type="button" class="easyui-linkbutton" iconCls="icon-search" onClick='appStaffObj.search();'>查询</button>
  <button  type="button" class="easyui-linkbutton" iconCls="icon-reload" onClick='appStaffObj.reset();'>重置</button>
  <a class="easyui-linkbutton" iconCls="icon-20130406015709810_easyicon_net_16" onClick='commonObj.reload();'>重载</a>
  <a class="easyui-linkbutton" iconCls="icon-user_add" plain="false" onClick='appStaffObj.add(this);'>新增用户</a>

</form>
</div>
<div id="dlg-app-staff-add" class="easyui-dialog" style="width:400px" closed="true" buttons="#dlg-app-staff-add-buttons">
	<form id="fm-app-staff-add" method="get">
	<div style="margin:0;padding:20px 25px">

    <div style="margin-bottom: 10px;">
	<label class="textbox-label">所属部门：</label>
	<select id="app-staff-add-dept_id" class="easyui-combobox" required="true" name="dept_id" style="width:50%;height:26px;">
	@foreach($data['depts'] as $dept)
	<option value="{{$dept['id']}}">{{ $dept['name'] }}</option>
	@endforeach
	</select>
	</div>
	<div style="margin-bottom: 10px;">
	<label class="textbox-label">部门职称：</label>
	<select id="app-staff-add-post_id" class="easyui-combobox" required="true" name="post_id" style="width:50%;height:26px;">
	@foreach($data['posts'] as $post)
	<option value="{{$post['id']}}">{{ $post['name'] }}</option>
	@endforeach
	</select>
	</div>
    <div style="margin-bottom:10px">
	<input  name="name" class="easyui-textbox"  required="true" label="真实姓名:" style="width:90%">
	</div>
	<div style="margin-bottom:10px">
	<input  name="account" class="easyui-textbox"  required="true" label="用户账号:" style="width:90%">
	</div>
	<div style="margin-bottom:10px">
	<input  name="mobile" class="easyui-textbox"  required="true" label="用户手机:" style="width:90%">
	</div>
	<div style="margin-bottom:10px">
	<input  name="email" class="easyui-textbox"  required="true" label="用户邮箱:" style="width:90%">
	</div>
	<div style="margin-bottom:10px">
	<input  name="password" class="easyui-textbox"  required="true" label="用户密码:" style="width:90%">
	</div>

	</div>
	</form>
</div>
<div id="dlg-app-staff-add-buttons">
<a class="easyui-linkbutton" iconCls="icon-page_save" onclick="appStaffObj.save(this);">保存数据</a>
<a class="easyui-linkbutton" iconCls="icon-page_cancel" onclick="appStaffObj.cancel(this);">放弃操作</a>
</div>

<div id="dlg-app-staff-edit" class="easyui-dialog" style="width:400px" closed="true" buttons="#dlg-app-staff-edit-buttons">
  <form id="fm-app-staff-edit" method="get">
   <div style="margin:0;padding:20px 25px">

	<div style="margin-bottom:10px;display:none;">
	<input type="hidden" id="app-staff-edit-id" name="id" class="easyui-textbox" abel="用户ID:" style="width:90%">
	</div>
	<div style="margin-bottom:10px;display:none;">
	<input type="hidden" id="app-staff-edit-status" name="status" class="easyui-textbox" label="用户状态:" style="width:90%">
	</div>
	<div style="margin-bottom: 10px;">
	<label class="textbox-label">所属部门：</label>
	<select id="app-staff-edit-dept_id" class="easyui-combobox" required="true" name="dept_id" style="width:50%;height:26px;">
	@foreach($data['depts'] as $dept)
	<option value="{{$dept['id']}}">{{ $dept['name'] }}</option>
	@endforeach
	</select>
	</div>
	<div style="margin-bottom: 10px;">
	<label class="textbox-label">部门职称：</label>
	<select id="app-staff-edit-post_id" class="easyui-combobox" required="true" name="post_id" style="width:50%;height:26px;">
	@foreach($data['posts'] as $post)
	<option value="{{$post['id']}}">{{ $post['name'] }}</option>
	@endforeach
	</select>
	</div>
	<div style="margin-bottom:10px">
	<input id="app-staff-edit-name" name="name" class="easyui-textbox"  required="true" label="用户名称:" style="width:90%">
	</div>
	<div style="margin-bottom:10px">
	<input id="app-staff-edit-account" name="account" class="easyui-textbox"  required="true" label="用户账号:" style="width:90%">
	</div>
	<div style="margin-bottom:10px">
	<input id="app-staff-edit-mobile" name="mobile" class="easyui-textbox"  required="true" label="用户手机:" style="width:90%">
	</div>
	<div style="margin-bottom:10px">
	<input id="app-staff-edit-email" name="email" class="easyui-textbox"  required="true" label="用户邮箱:" style="width:90%">
	</div>

   </div>
  </form>
</div>
<div id="dlg-app-staff-edit-buttons">
<a class="easyui-linkbutton" iconCls="icon-page_save" onclick="appStaffObj.modify(this);">保存数据</a>
<a class="easyui-linkbutton" iconCls="icon-page_cancel" onclick="appStaffObj.cancel(this);">放弃操作</a>
</div>

<div id="dlg-app-staff-app-relation" class="easyui-dialog" style="width:800px" closed="true" buttons="#dlg-app-staff-app-relation-buttons">
  <form id="fm-app-staff-app-relation" method="get">
   <div style="margin:0;padding:20px 25px">
      <table class="dialog-table" cellspacing="0" cellpadding="0">
       <thead>
        <tr>
         <th width="20%">应用名称</th>
         <th width="80%" class="text-center">权限分组</th>
        </tr>
       </thead>
       <tbody>
        @foreach($data['appsGroups'] as $appGroup)
         <tr>
          <td>
           <input onchange="appStaffObj.changeApp(this);" value="{{$appGroup['id']}}" id="app_id_{{$appGroup['id']}}" name="app_id" type="checkbox" />
           <label class="label label-success" for="app_id_{{$appGroup['id']}}">{{$appGroup['name']}}</label>
          </td>
          <td>
          	 <ul style="width:100%;float:left;padding:0px;margin:0px;">
          	 @foreach($appGroup['groups'] as $group)
          	  <li style="width:20%;float:left;list-style: none;">
          	  <a href="javascript:void(0);" style="display:block; text-decoration: none;margin:5px 0px;">
              <input onchange="appStaffObj.changeAuthGroup(this);" data="{{$appGroup['id']}}" value="{{$group['id']}}" id="app_group_id_{{$group['id']}}"  type="radio" name="group_id_{{$appGroup['id']}}">
              <label class="label label-info" for="app_group_id_{{$group['id']}}">{{$group['name']}}</label>
              </a>
              </li>
             @endforeach
            </ul>
          </td>
         </tr>
        @endforeach
       </tbody> 
	 </table>
   </div>
  </form>
</div>
<div id="dlg-app-staff-app-relation-buttons">
<a class="easyui-linkbutton" iconCls="icon-page_save" onclick="appStaffObj.modifyStaffAppRelation(this);">保存数据</a>
<a class="easyui-linkbutton" iconCls="icon-page_cancel" onclick="appStaffObj.cancel(this);">放弃操作</a>
</div>


<script>
require(['pages/admin/app/staff','pages/common/common'],function(appStaff,common){
common.init({});
appStaff.appStaffInit({
	get_list_url:"{{ route('admin.app.staff')}}",
	get_add_url:"{{ route('admin.app.staff.add')}}",
	get_edit_url:"{{ route('admin.app.staff.edit')}}",
	get_staff_apps:"{{ route('admin.app.staff.apps') }}",
	get_edit_staff_app_relation_url:"{{route('admin.app.staff.apps.relation.edit')}}",
	get_dept_json:'{!! $data["deptJson"] !!}',
	get_post_json:'{!! $data["postJson"] !!}',
  });
});
</script>
@stop
